class Admin::MenusController < AdminController
  
  def index
    @menus = Menu.all
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @menus }
    end  end
  
  def show
    @menu = Menu.find(params[:id])
    respond_to do |format|
      format.html # show.html.erb
      format.fbml
      format.xml  { render :xml => @menu }
    end
    
    
  end
  def new
    @menu = Menu.new
  end
  
  def create
    @menu = Menu.new(params[:menu]) 
    if @menu.save
      flash_notice(:menu_created)
      redirect_to admin_menus_url
    else
      render :action=>:new
    end
  end
  
  def destroy
    @menu = Menu.find(params[:id])
    @menu.destroy
    
    flash_notice(:menu_removed)
    respond_to do |format|
      format.html { redirect_to(admin_menus_url) }
      format.xml  { head :ok }
    end
  end
  
  def edit
    @menu = Menu.find(params[:id])
  end
  
  def update
    
    @menu = Menu.find(params[:id])
    respond_to do |format|
      if @menu.update_attributes(params[:menu])
        
        flash_notice(:menu_updated)
        format.html { redirect_to admin_menu_url(@menu) }
        format.xml  { head :ok }
      else
        flash_error(:menu_not_updated)
        format.html { render :action => "edit" }
        format.xml  { render :xml => @menu.errors, :status => :unprocessable_entity }
      end
    end
    
  end
  
end
